package com.sunrise.visual.frame.common
{
	//16指标1级界面小图chart xml格式化公共方法
	public class WidgetChartUtil
	{
		public function WidgetChartUtil()
		{
		}
		
		//柱形图
		public static function parseTwoChartXML(toolTip:String,seriesDatas:XML) {
			var xml:XML = <anychart>
							<margin all="0" />
							<settings>
								<animation enabled="True" />
							</settings>
							<charts>
								<chart plot_type="CategorizedVertical">
									<data_plot_settings default_series_type="Bar">
										<bar_series style="Silver" group_padding="0">
											<tooltip_settings enabled="true">
<font family="Microsoft Yahei" bold="false" size="12" />
												<format>
										{"{%Name}{numDecimals:0,thousandsSeparator:}\n{%SeriesName}:{%YValue}{numDecimals:2}"}
									</format>
								</tooltip_settings>
							</bar_series>
						</data_plot_settings>
						<chart_settings>
							<chart_background enabled="false">
								<inside_margin left="9" top="3" right="9" />
							</chart_background>
							<data_plot_background enabled="false" />
							<title enabled="false"/>
							<axes>
								<x_axis enabled="false"/>
								<y_axis enabled="false"/>
							</axes>
						</chart_settings>
						<data>{seriesDatas}</data>
						</chart>
						</charts>
						</anychart>;
		}
		
		private static function createBubbleSeriesFromAC(collection:Array,serieNames:String,pointNames:Array):XML {
			var seriesXML:XML = new XML("<series name='" + pointNames + "'/>");
			for(var i:int=0;i<collection.length;i++) {
				seriesXML.appendChild(<point name={collection[i][xField]}  y={collection[i][xdf]} selected={collection[i]['zt']}>);
				seriesXML.appendChild(<attributes><attribute name="flbm">{collection[i][flbm]}</attribute></attributes></point>);
			}
			return seriesXML;
		}
		
		public static function createSeriesFromAR(collection:Array,nameField:String,yField:String,seriesName:String=null):XML
		{
			var seriesXML:XML=<series/>;
			if(seriesName!=null) seriesXML.@name=seriesName;
			
			for(var i:int=0;i<collection.length;i++) {
				seriesXML.appendChild(<point name={collection[i][nameField]} y={collection[i][yField]}/>);
			}
			return seriesXML;
		}
		
		private static function createExtraLabels(text:String):XML {
			var extraLabelXML:XML=<extra_labels/>;
			extraLabelXML.appendChild(<label enabled="true">
			  <format>
				{text}
			  </format>
			  <position anchor="CenterBottom" halign="Center" valign="Top"/>
			</label>);
			return extraLabelXML;
		}
	}
}